package com.oreilly.ez.util;


import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class DateTool {



    public static int getLastDay(int year, int month) {
        int day = 1;
        Calendar cal = Calendar.getInstance();
        cal.set(year,month - 1,day);
        int last = cal.getActualMaximum(Calendar.DATE);
        System.out.println(last);
        return last;
    }




    public static List<String> dayList(int year,int month){

        DateTime first = new DateTime(year, month, 1, 0, 0, 0);

        int lastDay = getLastDay(year, month);
        List<String> dayList=new ArrayList<>();
        for (int i = 0; i < lastDay; i++) {
            dayList.add(first.plusDays(i).toString("yyyy-MM-dd"));
        }

        return dayList;
    }
}